package com.example.calories;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CalendarView;
import android.widget.Toast;

public class CalendarViews extends AppCompatActivity implements View.OnClickListener {
     CalendarView calendarView;
     Button back ;
     String datas;
     MainActivity mainActivity;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_calendar_view);
        calendarView = findViewById(R.id.calenderView);
        mainActivity = new MainActivity();
        back = findViewById(R.id.back);
        back.setOnClickListener(this);
        calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
            @Override
            public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
                Toast.makeText(CalendarViews.this,year + "年" + month + "月" + dayOfMonth + "日", Toast.LENGTH_SHORT).show();
                datas=year+"-"+month+"-"+dayOfMonth;
            }
        });
    }
    @Override
    public void onClick(View v) {
        Intent intent = new Intent(CalendarViews.this,MainActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString("dates", datas);
        intent.putExtras(bundle);
        startActivity(intent);
    }
}
